﻿// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
//引入windows编程头文件
#include <Windows.h>
//引入标准IO头文件
#include <stdio.h>
//引入资源头文件
#include "resource.h"
//引入自己写的实现
#include "mem_rw_util.h"

INT_PTR CALLBACK Dlgproc(
    HWND hModule,
    UINT message,
    WPARAM ext_msg_1,
    LPARAM ext_msg_2
){
    switch (message){
        case WM_INITDIALOG: {
            readWXData(hModule);
            break;
        }
        //组件单击事件
        case WM_COMMAND: {
            switch (ext_msg_1)
            {
                case mem_r: {
                    readWXData(hModule);
                    break;
                }
                case mem_w: {
                    writeData(hModule);
                    break;
                }
                default:
                    break;
            }
            break;
        }
        //对话框关闭事件
        case WM_CLOSE: {
            EndDialog(hModule, 0);
            break;
        }
        //默认不做任何处理
        default:
            break;
    }
    return false;
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call){
        case DLL_PROCESS_ATTACH: {
            DialogBox(hModule,MAKEINTRESOURCE(MAIN),NULL,Dlgproc);
            break;
        }
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            break;
    }
    return TRUE;
}

